package com.blb.controller;

import com.blb.pojo.Banner;
import com.blb.service.BannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin(origins = "*")
@Api(tags = "轮播图")
public class BannerController {

    @Autowired
    private BannerService bannerService;

    @ApiOperation(value = "根据位置信息查询轮播图1代表首页头部 2首页解决方案")
    @GetMapping("/banner/{num}")
    public ResponseEntity<List<Banner>> findAll(@ApiParam(name = "num",value = "轮播位置",required = true) @PathVariable("num")int num){
        List<Banner> byLocation = bannerService.findByLocation(num);
        return ResponseEntity.ok(byLocation);
    }



}
